class NewbooksController < ApplicationController
  def new
    @user = current_user
    @search = params[:search_option].to_i
    @categories = Category.all
    @hot_books = Book.search_hot_book() 
    
    case @search
    when 0 then @books = Book.search_new_book_in_day().page(params[:page]).per(12)
    when 1 then @books = Book.search_new_book_in_week().page(params[:page]).per(12)
    when 2 then @books = Book.search_new_book_in_month().page(params[:page]).per(12)
    end

  end
  
  def show
        @search_option = params[:search_option]
    if (@search_option != nil)
      redirect_to searchbooks_new_path(:search_option => params[:search_option])
    end
  end
end
